package com.zzhb;

import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Identity {

	@Autowired
	RepositoryService repositoryService;

	@Autowired
	RuntimeService runtimeService;

	@Autowired
	TaskService taskService;

	@Autowired
	HistoryService historyService;

	@Autowired
	IdentityService identityService;

	@Test // 创建用户组
	public void test1() {
		Group group = identityService.newGroup("3");
		group.setName("市场部3");
		group.setType("市场部3");
		identityService.saveGroup(group);
	}

	@Test // 修改用户组
	public void test2() {
		Group group = identityService.createGroupQuery().groupId("1").singleResult();
		group.setName("市场2部");
		group.setType("市场部2");
		identityService.saveGroup(group);
	}

	@Test // 删除用户组
	public void test3() {
		identityService.deleteGroup("1");
	}
	
	
	@Test // 创建用户
	public void test4() {
		User user = identityService.newUser("2");
		user.setFirstName("chenhj2");
		identityService.saveUser(user);
	}
	
	@Test // 创建用户组绑定用户
	public void test5() {
		identityService.createMembership("1", "14e354d1-55ef-41b1-a0c9-4911aaa8f9ca");
	}
	
	
	
}
